package com.yunxiao.cloud.web.task;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;

import java.nio.charset.StandardCharsets;

/**
 * @description: MessageHandler
 * @author: yunxiao
 * @date: 2020/1/8 8:47
 * @version: V1.0
 **/
public class MessageHandler {

    private static final Logger log = LoggerFactory.getLogger(MessageHandler.class);

    public void handleMessage(Message message) {
        log.debug("Message " + JSON.toJSONString(message));
        String messageBody = new String(message.getBody(), StandardCharsets.UTF_8);
        log.debug("Message Body " + messageBody);
    }

    public void handleMessage(byte[] message) {
        String messageBody = new String(message, StandardCharsets.UTF_8);
        log.debug("Message Body " + messageBody);
    }
}
